import requests
from loguru import logger


def get_proxy():
    url = "http://http.tiqu.letecs.com/getip3?num=1&type=1&pro=&city=0&yys=0&port=1&pack=29238&ts=0&ys=0&cs=0&lb=1&sb=0&pb=4&mr=1&regions=&tl=2"
    try:
        response = requests.get(url, timeout=3)
        proxy_str = response.text.replace("\r\n", "")
        logger.info(f"proxy: {proxy_str}")
        return {"http": f"http://{proxy_str}", "https": f"http://{proxy_str}"}
    except Exception as e:
        logger.error(e)
        return None

cookies = {
    'BAIDUID_BFESS': '9ECF9B805B60F7C6DC8480209A241E90:FG=1',
    'ab_sr': '1.0.1_NjQyY2IzYmVjZGQ4NWYxM2Y3ZWNlNDcwODExOTlmYjQxOGY1MWQyNDFiNGI2MzMzYjZiZDU5M2I4NWM5YzQ5YjM3OTAzMjdiZTViYjE1MmVlZDc5NmY5ODg2ZGQ3MTAxYzU1ZGZkMjY4MGRkNzcxNDg1MTI1Yjk3MTQwZDg2NmUwZTdlNGFkMGVlMDY5NmUyMDIxZDAyYWM4OTQzODFiMQ==',
}

headers = {

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
}

params = {
    'pid': '46608940463097',
}
proxy = get_proxy()
response = requests.get('https://aiqicha.baidu.com/detail/basicAllDataAjax', params=params, cookies=cookies, headers=headers, proxies=proxy, timeout=5, verify=False)
print(response.text)